﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

public partial class xiugai : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string ConString = "Data Source=.;Initial Catalog=smdb;Integrated Security=True";

        string sql2 = "select * from users where name='" + Session["username"].ToString() + "'";
        SqlConnection con = new SqlConnection(ConString);
        con.Open();//打开连接
        SqlCommand cmd = new SqlCommand(sql2, con);
        SqlDataReader dr = cmd.ExecuteReader();
        while (dr.Read())
        {
            namete.Text = dr["name"].ToString();//texbox1的值
            psdte.Text = dr["psd"].ToString();//texbox2的值
            emte.Text = dr["email"].ToString();//texbox3的值
            zyte.Text = dr["zhuanye"].ToString();//texbox3的值
            xhte.Text = dr["xuehao"].ToString();//texbox3的值  
        }
        con.Close();//关闭连接


    }

    protected void rebt_Click(object sender, EventArgs e)
    {
        string Sql = "Data Source=.;Initial Catalog=smdb;Integrated Security=True";


        using (SqlConnection scon = new SqlConnection(Sql))
        {
            
            string str1 = "update users set psd = '" + xgpswtext.Text + "',email='"+emailtext.Text+"',zhuanye='"+zytext.Text+"',xuehao='"+xhtext.Text+"'  where name = '" + Session["username"].ToString()+"'";
            scon.Open();
            SqlCommand command = new SqlCommand
            {
                Connection = scon,
                CommandText = str1
            };
            int obj = command.ExecuteNonQuery();
            scon.Close();
            HttpContext.Current.Response.Redirect("login.aspx");
        }
    }

    protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void ListView1_SelectedIndexChanged1(object sender, EventArgs e)
    {

    }
}